<template>
  <el-row class="row-header">
    <div class="hearder-header">
      <ul class="ul-header">
        <li class="li-header">猜你喜欢</li>
        <li class="title-header activte">为你甄选最合适的</li>
      </ul>
    </div>
    <div class="row-content">
      <div class="wrapper">
        <youlike v-for="(item, index) in youlikeList1" :key="index" :item="item"></youlike>
      </div>
    </div>
  </el-row>
</template>
<script>
import youlike from "../../com/youlike";
export default {
  components: {
    youlike
  },
  computed: {
    youlikeList1 () {
      let ret = this.getlist(this.$store.state.home.youlikeline1)
      return ret.map(item => {
        return {
          img: item.photos[0].url,
          title: item.name,
          name: item.adname,
          address: item.address,
          rateing: item.biz_ext.rating.length? parseInt(item.biz_ext.rating) : 0,
          price: item.biz_ext.cost.length ? item.biz_ext.cost : '暂无报价'
        }
      })
    }
  },
  methods: {
    getlist (list) {
      let ret = []
      var num = (list.length < 5)? list.length : 5
      for (var i = 0; i < num; i++) {
        if (list[i].photos.length) {
          ret.push(list[i])
        } else {
          i--
        }
      }
      return ret
    }
  }
}
</script>
<style scoped lang="scss">
  .row-header{
    padding-left: 20px;
    margin-top: 40px;
  }
  .hearder-header{
    width: 100%;
    height: 44px;
    background: linear-gradient(to right, rgb(88, 174, 221) 2%, rgb(66, 191, 205) 97%) rgb(88, 174, 221);
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
  }
  .ul-header{
    color: #fff;
    line-height: 44px;
    li {
      list-style: none;
      margin-left: 5px;
      margin-right: 5px;
      float: left;
      position: relative;
      cursor: pointer;
    }
  }
  .li-header{
    font-size: 18px;
    cursor: none;
    margin-left: 20px !important;
    margin-right: 15px !important;
  }
  .activte{
    &:after{
      position: absolute;
      content: "";
      border-left: 5px solid transparent;
      border-bottom: 7px solid #fff;
      border-right: 5px solid transparent;
      display: block;
      width: 2px;
      top: 37px;
      right: 0;
      left: 0;
      margin: auto;
    }
  }
  .title-header{
    font-size: 14px;
  }
  .more-header {
    font-size: 14px;
    float: right !important;
    padding-right: 5px;
    margin-right: 20px;
  }
  .row-content{
    border: 1px solid #E5E5E5;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
    border-top: none;
    padding-top: 5px;
    box-sizing: border-box;
  }
  .wrapper{
    width: 100%;
    display: flex;
    flex: 1;
    flex-wrap: wrap;
  }
</style>
